package com.itheima.streamdemo.myStream;

import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class MyStreamDemo02 {
    public static void main(String[] args) {
        //collection体系的集合可以直接用默认方法stream()生成流
        List<String> list = new ArrayList<>();
        Stream<String> stream = list.stream();

        Set<String> set = new HashSet<>();
        Stream<String> stream1 = set.stream();

        //Map体系的集合间接生成流
        Map<String, Integer> map = new HashMap<>();
        Stream<String> stream2 = map.keySet().stream();

        Stream<Integer> stream3 = map.values().stream();

        //数组可以通过工具类Arrays中的静态方法stream生成流

        int[] arr = {1, 2, 3, 4, 5};
        IntStream stream4 = Arrays.stream(arr);

        //同种数据类型的多个数据可以用Stream接口当中的静态方法of(T... values)生成流

        Stream<String> va = Stream.of("va", "lu", "e");

    }
}
